package com.zzyl.controller.manager;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(path = "/nursing/project")
@Api(tags = "护理项目管理")
public class NursingProjectController {

    @Autowired
    private NursingProjectService nursingProjectService;

    @GetMapping
    @ApiOperation("分页查询护理项目列表")
    public ResponseResult<PageResponse<NursingProjectVo>> findNursingProject(String name, Integer status, Integer page, Integer pageSize) {
        PageResponse<NursingProjectVo> pageResponse = nursingProjectService.findNursingProject(name, status, page, pageSize);
        return ResponseResult.success(pageResponse);
    }

    @PostMapping
    @ApiOperation("新增护理项目")
    public ResponseResult<Void> create(@RequestBody NursingProjectDto nursingProjectDto) {
        nursingProjectService.addNursingProject(nursingProjectDto);
        return ResponseResult.success();
    }

    @GetMapping(path = "/{id}")
    @ApiOperation("查询护理项目详情")
    public ResponseResult<NursingProjectVo> findById(@PathVariable("id") Long id) {
        NursingProjectVo nursingProjectVo = nursingProjectService.findById(id);
        return ResponseResult.success(nursingProjectVo);
    }

    @PutMapping
    @ApiOperation("修改护理项目")
    public ResponseResult<Void> modifyNursingProject(@RequestBody NursingProjectDto nursingProjectDto){
        nursingProjectService.modifyNursingProject(nursingProjectDto);
        return ResponseResult.success();
    }

}
